package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.css.CSSDeclaration;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appmarket.framework.widget.CustomActionBar;
import com.huawei.appmarket.framework.widget.RenderImageView;
import com.huawei.appmarket.framework.widget.RenderImageView.b;
import com.huawei.appmarket.service.store.awk.bean.SubstanceInfoBean;
import o.azb;
import o.cgz;
import o.ckd;
import o.dke;
import o.Logger;
import o.eho;
import o.epv;
import o.eqx;
import o.eqz;
import o.erq;
import o.evf;
import o.ewm.c;
import o.ewm.d;
import o.ewm.e;
import o.ewm.j;

public class ImmersiveHeadDlCard extends BaseDistCard implements eqz, b {
    private TextView ʻ;
    private TextView ʼ;
    private ImageView ʽ;
    private RelativeLayout ˊॱ;
    private RenderImageView ˋ;
    private boolean ॱˊ = false;
    private boolean ॱॱ = false;
    private String ᐝ;

    public ImmersiveHeadDlCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˋ((DownloadButton) view.findViewById(j.ˋʹ));
        this.ˋ = (RenderImageView) view.findViewById(j.ˋՙ);
        this.ʼ = (TextView) view.findViewById(j.ˋߵ);
        this.ʻ = (TextView) view.findViewById(j.ˋᵔ);
        this.ʽ = (ImageView) view.findViewById(j.ˋٴ);
        this.ˊॱ = (RelativeLayout) view.findViewById(j.ˋᵎ);
        this.ˋ.setListener(this);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        SubstanceInfoBean substanceInfoBean = (SubstanceInfoBean) cardBean;
        if (!this.ॱˊ) {
            int ˎ = epv.ˎ(this.ˊˋ.getContext());
            float f = 1.25f;
            if (substanceInfoBean.ʻˋ() == 8) {
                f = 0.5625f;
            }
            int i = (int) (f * ((float) ˎ));
            LayoutParams layoutParams = (LayoutParams) this.ˊॱ.getLayoutParams();
            layoutParams.width = ˎ;
            layoutParams.height = i;
            this.ˊॱ.setLayoutParams(layoutParams);
            this.ॱˊ = true;
        }
        this.ᐝ = substanceInfoBean.ʾॱ();
        eqx.ˏ(this.ʽ, substanceInfoBean.ॱˌ(), "app_default_icon");
        eqx.ˎ(this.ˋ, substanceInfoBean.ʼˊ(), "image_default_icon", this, true);
        if (substanceInfoBean.ٴ() != 0) {
            this.ʻ.setText(substanceInfoBean.ߴ());
        } else {
            this.ʻ.setText(substanceInfoBean.ʻᐝ());
        }
        this.ʼ.setText(substanceInfoBean.ʻˊ());
    }

    public void ॱ(Bitmap bitmap) {
        int i = -1;
        if (bitmap != null) {
            try {
                int ॱ = erq.ॱ(this.ᐝ, bitmap);
                this.ˋ.setRenderColor(ॱ);
                this.ˋ.setRenderScale(0.3f);
                if (!this.ॱॱ) {
                    CustomActionBar.ˎ(this.ˋ.getContext(), ॱ, this.ˋ.getHeight());
                    boolean ˏ = erq.ˏ(ॱ);
                    this.ʻ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
                    if (ˏ) {
                        this.ʻ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
                    } else {
                        i = -16777216;
                    }
                    this.ʼ.setTextColor(i);
                    this.ʻ.setTextColor(i);
                    i = c.ˊˊ;
                    int i2 = e.ﾞ;
                    if (evf.ˊ(ʽ())) {
                        new eho(i, i2, c.ᐝॱ).ॱ(ʽ());
                    } else {
                        ckd o_dke = new dke(this.ʻ.getContext(), this.ʼॱ.getResources().getColor(i), -16777216, i2, false, erq.ˊ(-1, 0.6f));
                        if (ʽ() != null) {
                            ʽ().setButtonStyle(o_dke);
                            ʽ().setIsImmersion(true);
                            ʽ().ॱ();
                        }
                    }
                    this.ॱॱ = false;
                }
            } catch (IllegalStateException e) {
                Logger.e("ImmersiveHeadDlCard", e.toString());
            }
        }
    }

    public boolean ˋ(CSSDeclaration cSSDeclaration) {
        CSSValue propertyValue = cSSDeclaration.getPropertyValue(CSSPropertyName.FONT_COLOR);
        if (propertyValue != null && (propertyValue instanceof CSSMonoColor)) {
            this.ॱॱ = true;
        }
        return false;
    }
}
